const hc$rule$basic = {
    data: function() {
        return {
            rule: {},
            ruletype: ''
        }
    },
    props: {
        'ruledef': {
            type: Object,
            default () {
                return {};
            }
        }
    },
    mounted: function() { },
    watch: {
        ruledef: { //load the reference list when show dialog
            immediate: true,
            handler: function(nv, ov) {
                if(!nv.rpath) return;
                this.rule = nv
                this.ruletype = window.top.$config ? window.top.$config.componentMap[nv.rtype].rname : nv.rtype
            }
        }
    },
    methods: { },
    template: `
                <el-form label-width="100px">
                    <el-form-item label="规则类型">
                        <el-input   :disabled='true' :value="ruletype"></el-input>
                    </el-form-item>
                	<el-form-item label="规则名称">
                        <el-input  v-model.trim="rule.rname"></el-input>
                	</el-form-item>
                    <el-form-item label="规则代码">
                        <!-- rule.rpath.substr(rule.rpath.indexOf('/')+1)-->
                        <el-input :disabled='true' :value="rule.rpath"></el-input>
                    </el-form-item>
                    <el-form-item label="备注说明">
                        <el-input type="textarea" v-model="rule.rmemo" placeholder="决策组件备注说明信息" rows="2">
                        </el-input>
                    </el-form-item>
                    <el-form-item label="创建用户">
                        <el-col :span='10'><el-input :disabled='true' :value="rule.createdUser"></el-input></el-col>
                        <el-col class="line" :span='4'><label class='el-form-item__label' style='width:100%;text-align:right'>创建时间</label></el-col>
                        <el-col :span='10'> <el-input :disabled='true' :value="rule.createdTime"></el-input> </el-col>
                    </el-form-item>
                    <el-form-item label="最后更新用户">
                        <el-col :span='10'><el-input :disabled='true' :value="rule.updatedUser"></el-input></el-col>
                        <el-col class="line" :span='4'><label class='el-form-item__label' style='width:100%;text-align:right'>最后更新时间</label></el-col>
                        <el-col :span='10'> <el-input :disabled='true' :value="rule.updatedTime"></el-input> </el-col>
                    </el-form-item>
                </el-form>
                
                `
}

Vue.component('hc-rule-basic', hc$rule$basic)


const dlgtemplate =
    `
<el-dialog :visible.sync="visible" title="规则基本信息" width="60%">
     <hc-rule-basic :ruledef='ruleDef'></hc-rule-basic>
    <el-form label-width="80px">
        <el-form-item>
            <el-button @click='handleSettingSubmit' type="primary">确认</el-button>
        </el-form-item>
    </el-form>
</el-dialog>
`;

const vmconfig = {
    template: dlgtemplate,
    data: function() {
        return {
            ruleDef:{},
            visible: false,
        }
    },
    methods: {
        handleSettingSubmit: function() {
            this.visible = false;
        },
        show: function(ruleDef) {
            this.ruleDef = ruleDef;
            this.visible = true;
        },
    },
};

function RuleBasicSetting(userconfig) {
    userconfig = userconfig || {}
    let vm = new Vue(vmconfig);
    vm = Object.assign(vm, userconfig)
    if (userconfig.el == undefined) { 
        vm.$mount();
        document.body.appendChild(vm.$el);
    }
    return vm;
}

export default RuleBasicSetting